From: Tim Starling Date: Wed, 12 Nov 2003 10:21:28 +0000 (+0000) Subject: Latest features and bug fixes imported from stable X-Git-Tag: 1.1.0~178 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=596f4b09ceee8eee7b5669adb12163c26c9e18f8;p=lhc%2Fweb%2Fwiklou.git Latest features and bug fixes imported from stable --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 69ad5e47ff..0c7f1d9bb2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -42,9 +42,12 @@ $wgDBmysql4 = false; # Set to true to use enhanced fulltext search # memcached settings # See docs/memcached.doc # -$wgUseMemCached = false; # Will be set to false in Setup.php, if the server isn't working +$wgMemCachedDebug = false; # Will be set to false in Setup.php, if the server isn't working +$wgUseMemCached = false; $wgMemCachedServers = array( "127.0.0.1:11000" ); $wgMemCachedDebug = false; +$wgSessionsInMemcached = false; +$wgLinkCacheMemcached = false; # Not fully tested # Language settings # @@ -105,6 +108,11 @@ $wgFileCacheDirectory = "{$wgUploadDirectory}/cache"; $wgCookieExpiration = 2592000; +# Set to set an explicit domain on the login cookies +# eg, "justthis.domain.org" or ".any.subdomain.net" +$wgCookieDomain = ""; +$wgCookiePath = "/"; + $wgAllowExternalImages = true; $wgMiserMode = false; # Disable database-intensive features $wgUseTeX = false; @@ -120,7 +128,7 @@ $wgDebugFunctionEntry = 0; # Output debug message on every wfProfileIn/wfProfile $wgDisableCounters = false; $wgDisableTextSearch = false; $wgDisableSearchUpdate = false; # If you've disabled search semi-permanently, this also disables updates to the table. If you ever re-enable, be sure to rebuild the search table. -$wgDisableUploads = false; +$wgDisableUploads = true; # Uploads have to be specially set up to be secure $wgDisableAnonTalk = false; # We can serve pages compressed in order to save bandwidth, diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 801bde2505..261f5eeb29 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -466,6 +466,7 @@ function wfRecordUpload( $name, $oldver, $size, $desc ) $now = wfTimestampNow(); $won = wfInvertTimestamp( $now ); + $size = IntVal( $size ); if ( $wgUseCopyrightUpload ) { @@ -481,7 +482,7 @@ function wfRecordUpload( $name, $oldver, $size, $desc ) if ( 0 == wfNumRows( $res ) ) { $sql = "INSERT INTO image (img_name,img_size,img_timestamp," . "img_description,img_user,img_user_text) VALUES ('" . - wfStrencode( $name ) . "',{$size},'{$now}','" . + wfStrencode( $name ) . "',$size,'{$now}','" . wfStrencode( $desc ) . "', '" . $wgUser->getID() . "', '" . wfStrencode( $wgUser->getName() ) . "')"; wfQuery( $sql, DB_WRITE, $fname ); @@ -671,4 +672,25 @@ function wfLoadAllMessages() wfFreeResult( $res ); return $messages; } + +function wfQuotedPrintable( $string, $charset = "" ) +{ + # Probably incomplete; see RFC 2045 + if( empty( $charset ) ) { + global $wgInputEncoding; + $charset = $wgInputEncoding; + } + $charset = strtoupper( $charset ); + $charset = str_replace( "ISO-8859", "ISO8859", $charset ); // ? + + $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff='; + $replace = $illegal . '\t ?_'; + if( !preg_match( "/[$illegal]/", $string ) ) return $string; + $out = "=?$charset?Q?"; + $out .= preg_replace( "/([$replace])/e", 'sprintf("=%02X",ord("$1"))', $string ); + $out .= "?="; + return $out; +} + + ?> diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 212b214aef..9b0f07757e 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -75,9 +75,11 @@ class LinkCache { $this->clearLink( $title ); } - function clearLink( $title ) { - global $wgMemc; - $wgMemc->delete( $this->getKey( $title ) ); + function clearLink( $title ) + { + global $wgMemc, $wgLinkCacheMemcached; + if( $wgLinkCacheMemcached ) + $wgMemc->delete( $this->getKey( $title ) ); } function suspend() { $this->mActive = false; } @@ -114,8 +116,11 @@ class LinkCache { wfProfileOut( $fname ); return 0; } + + $id = FALSE; + if( $wgLinkCacheMemcached ) + $id = $wgMemc->get( $key = $this->getKey( $title ) ); - $id = $wgMemc->get( $key = $this->getKey( $title ) ); if( $id === FALSE ) { $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . "{$ns} AND cur_title='" . wfStrencode( $t ) . "'"; @@ -127,7 +132,8 @@ class LinkCache { $s = wfFetchObject( $res ); $id = $s->cur_id; } - $wgMemc->add( $key, $id, time()+3600 ); + if( $wgLinkCacheMemcached ) + $wgMemc->add( $key, $id, time()+3600 ); } if ( 0 == $id ) { $this->addBadLink( $title ); } else { $this->addGoodLink( $id, $title ); } diff --git a/includes/MemcachedSessions.php b/includes/MemcachedSessions.php new file mode 100644 index 0000000000..4b72e58f36 --- /dev/null +++ b/includes/MemcachedSessions.php @@ -0,0 +1,54 @@ +get( memsess_key( $id ) ); + if( $data === FALSE ) return ""; + return $data; +} + +function memsess_write( $id, $data ) { + global $wgMemc; + $wgMemc->set( memsess_key( $id ), $data, 3600 ); + return true; +} + +function memsess_destroy( $id ) { + global $wgMemc; + $wgMemc->delete( memsess_key( $id ) ); + return true; +} + +function memsess_gc( $maxlifetime ) { + # NOP: Memcached performs garbage collection. + return true; +} + +session_set_save_handler( "memsess_open", "memsess_close", "memsess_read", "memsess_write", "memsess_destroy", "memsess_gc" ); + +?> diff --git a/includes/Setup.php b/includes/Setup.php index 038e1178e3..826f15a0be 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -77,6 +77,19 @@ if( ! class_exists( $wgLangClass ) ) { } $wgLang = new $wgLangClass(); +if( !$wgCommandLineMode ) { + if( $wgSessionsInMemcached ) { + include_once( "$IP/MemcachedSessions.php" ); + } + session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain ); + session_cache_limiter( "private, must-revalidate" ); + session_start(); + session_register( "wsUserID" ); + session_register( "wsUserName" ); + session_register( "wsUserPassword" ); + session_register( "wsUploadFiles" ); +} + $wgUser = User::loadFromSession(); $wgDeferredUpdateList = array(); $wgLinkCache = new LinkCache(); diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index 2e01937f25..621a237d13 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -108,14 +108,18 @@ ORDER BY cur_title LIMIT {$indexMaxperpage}"; $res = wfQuery( $sql, DB_READ, "indexShowChunk" ); - # FIXME: Dynamic column widths, backlink to main list, - # side links to next and previous +# FIXME: Dynamic column widths, backlink to main list, +# side links to next and previous $n = 0; - $out = "\n"; + $out = "
\n"; while( $s = wfFetchObject( $res ) ) { - $out .= ""; + $t = Title::makeTitle( 0, $s->cur_title ); + if( $t ) { + $link = $sk->makeKnownLinkObj( $t ); + } else { + $link = "[[" . htmlspecialchars( $s->cur_title ) . "]]"; + } + $out .= ""; $n = ++$n % 3; if( $n == 0 ) { $out .= "\n"; @@ -125,7 +129,7 @@ LIMIT {$indexMaxperpage}"; $out .= "\n"; } $out .= "
" . - $sk->makeKnownLink( $s->cur_title ) . - "$link
"; - #return $out; +#return $out; $wgOut->addHtml( $out ); } diff --git a/includes/SpecialEmailuser.php b/includes/SpecialEmailuser.php index 8ae02b2800..ababac206f 100644 --- a/includes/SpecialEmailuser.php +++ b/includes/SpecialEmailuser.php @@ -105,17 +105,20 @@ class EmailUserForm { { global $wgOut, $wgUser, $wgLang, $wgOutputEncoding; global $wpSubject, $wpText, $target; + + $from = wfQuotedPrintable( $wgUser->getName() ) . " <" . $wgUser->getEmail() . ">"; + $to = wfQuotedPrintable( $this->mAddress ); - $from = $wgUser->getName() . " <" . $wgUser->getEmail() . ">"; $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" . "Content-transfer-encoding: 8bit\r\n" . "From: {$from}\r\n" . "Reply-To: {$from}\r\n" . - "To: {$this->mAddress}\r\n" . - "X-Mailer: Pediawiki interuser e-mailer"; - mail( $this->mAddress, $wpSubject, $wpText, $headers ); + "To: {$to}\r\n" . + "X-Mailer: MediaWiki interuser e-mailer"; + mail( $this->mAddress, wfQuotedPrintable( $wpSubject ), $wpText, $headers ); + $success = wfLocalUrl( $wgLang->specialPage( "Emailuser" ), "target={$target}&action=success" ); diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 116ec67901..ba5fce1440 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -169,9 +169,11 @@ function wfSpecialUndelete( $par ) wfQuery( $sql, DB_WRITE, $fname ); - # Touch the log? - - $wgOut->addWikiText(str_replace("$1", $target, wfMsg("undeletedtext"))); + # Touch the log? + $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) ); + $log->addEntry( wfMsg( "undeletedarticle", $target ), "" ); + + $wgout->addwikitext(str_replace("$1", $target, wfmsg("undeletedtext"))); return 0; } ?>